<?

ini_set('display_errors', 'On');
ini_set('error_reporting', E_ALL );

include_once("bootstrap.inc.php");

require_once("org/json/JSON.php");
$json = new Services_JSON();

require_once("com/borderwaitmaps/entities/BorderCrossing.php");
require_once("com/borderwaitmaps/entities/Lane.php");
require_once("com/borderwaitmaps/entities/Location.php");
require_once("com/borderwaitmaps/entities/VehicleFlow.php");

require_once("com/borderwaitmaps/json/BorderCrossingParser.php");

$bc = new BorderCrossing();
$bc->setName("Sample Crossing");
$bc->setCountry("UNITED_STATES");
$bc->setAlternateCrossingName("Alt Name");
$bc->setHours("9-12");

// set location
$location = new Location();
$location->setCity("My City");
$location->setLatitude("40.23456");
$location->setLongitude("111.123455");
$bc->setLocation($location);

// set commercial flow
$commFlow = new VehicleFlow();
	$commLane1 = new Lane();
	$commLane1->setName("Standard");
	$commLane1->setDelay("12");
	$commFlow->setPrimaryLane($commLane1);
	
	$commLane2 = new Lane();
	$commLane2->setName("Fast");
	$commLane2->setDelay("8");
	$commFlow->setSecondaryLane($commLane2);
$bc->setCommercialVehicleFlow($commFlow);	

// set passenger flow
$passFlow = new VehicleFlow();	
	$passLane1 = new Lane();
	$passLane1->setName("Standard");
	$passLane1->setDelay("4");
	$passFlow->setPrimaryLane($passLane1);
	
	$passLane2 = new Lane();
	$passLane2->setName("Nexus");
	$passLane2->setDelay("9");
	$passFlow->setSecondaryLane($passLane2);
$bc->setPassengerVehicleFlow($passFlow);

// init a parser, marshall the entity as array
$parser = new BorderCrossingParser();
$bc_parsed = $parser->marshall($bc);
$jd = $json->encode($bc_parsed);
print $jd;

?>
